package com.gitee.alg

import com.gitee.alg.sort.Algorithm
import com.gitee.alg.sort.sorting
import java.lang.Thread.sleep
import kotlin.random.Random
import kotlin.system.measureTimeMillis

/**
 * Project Name: alg
 * Des:
 * Package:com.gitee.alg
 * @author Arlo Sun
 * @date 2021/4/26 - 10:59
 */

fun main(args: Array<String>) {
    println("Welcome")
    warm()

    val init = { _: Int -> Random.nextInt(100) }

    val array = Array(21, init)

    println("Before sort   : ${array.contentToString()}")


    Algorithm.values().forEach {
        array.sorting(algorithm = it)
        array.sorting(ascend = false, algorithm = it)
    }


}

class Dummy(val int: Int)

fun warm() {
    val cost = measureTimeMillis {
        repeat(10) { val t = Dummy(it); sleep(100) }
    }
    println("Jvm warm up completed , cost time: $cost ms")
}


